package com.heima.admin.job;

import com.heima.admin.service.WemediaNewsAutoScanService;
import com.heima.feigns.wemedia.WemediaFeign;
import com.xxl.job.core.biz.model.ReturnT;
import com.xxl.job.core.handler.annotation.XxlJob;
import lombok.extern.slf4j.Slf4j;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;
import java.util.List;

@Component
@Slf4j
public class WeMediaNewsAutoScanJob {

    @Resource
    WemediaFeign wemediaFeign;

    @Resource
    WemediaNewsAutoScanService wemediaNewsAutoScanService;

    @XxlJob(value = "wemediaAutoScanJob")
    public ReturnT<String> autoScanJob(@Param("param") String param) {
        //查询所以未发布的文章
        List<Integer> release = wemediaFeign.findRelease();
        log.info("自媒体文章审核调度任务开始执行....");
        //遍历集合并调用自动审核方法
        for (Integer wnNewsId : release) {

            wemediaNewsAutoScanService.autoScanByMediaNewsId(wnNewsId);
        }
        log.info("自媒体文章审核调度任务结束执行....");
        return ReturnT.SUCCESS;
    }
}
